<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<c:import url="/WEB-INF/jsp/head.jsp"/>
</head>
<body>

	<c:import url="/WEB-INF/jsp/cabecalho.jsp"/>
	
	<h3 align="center">Cadastro de Curso</h3>
	
	<form method="post" action="<c:url value="/curso/salvar"/>">
	
		<c:if test="${not empty errors}">
			<div id="erros" style="color:red" class="erros">
				Foram encontrados erros no cadastro:<br/>
				<ul>
				<c:forEach var="error" items="${errors}">
				    <li>${error.message}</li>
				</c:forEach>
				</ul>
			</div>
		</c:if>
	
		<table align="center" width="100%" border="0">
			<tr>
				<td width="50%" align="right">Id:</td>
				<td width="10"></td>
				<td width="50%" align="left">
					<input type="text" name="curso.id" id="curso.id" value="${curso.id}" readonly="readonly" style="width:50px" class="campoDesabilitado" />
				</td>
			</tr>
			<tr>
				<td width="50%" align="right">Data Início:</td>
				<td width="10"></td>
				<td width="50%" align="left"><input type="text" name="curso.dataInicio" id="cursoDataInicio" value="<fmt:formatDate value='${curso.dataInicio}' pattern='dd/MM/yyyy' />" style="width:100px"/></td>
			</tr>
			<tr>
				<td width="50%" align="right">Data Fim:</td>
				<td width="10"></td>
				<td width="50%" align="left"><input type="text" name="curso.dataFinal" id="cursoDataFinal" value="<fmt:formatDate value='${curso.dataFinal}' pattern='dd/MM/yyyy' />" style="width:100px"/></td>
			</tr>
			<tr>
				<td width="50%" align="right">Sala:</td>
				<td width="10"></td>
				<td width="50%" align="left"><input type="text" name="curso.sala" id="cursoSala" value="${curso.sala}" style="width:200px"/></td>
			</tr>
			<tr>
				<td width="50%" align="right">Professor:</td>
				<td width="10"></td>
				<td width="50%" align="left">
					<select name="curso.professor.id" id="cursoProfessorId">
						<c:forEach var="professor" items="${professorList}">
							<option value="${professor.id}" <c:if test="${professor.id == curso.professor.id}">selected="selected"</c:if> >${professor.nome}</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td width="50%" align="right">Disciplina:</td>
				<td width="10"></td>
				<td width="50%" align="left">
					<select name="curso.disciplina.id" id="cursoDisciplinaId">
						<c:forEach var="disciplina" items="${disciplinaList}">
							<option value="${disciplina.id}" <c:if test="${disciplina.id == curso.disciplina.id}">selected="selected"</c:if> >${disciplina.nome}</option>
						</c:forEach>
					</select>
				</td>
			</tr>
		</table>
		
		<br /><br />
		
		<div align="center">
			<input type="submit" name="btnEnviar" id="btnEnviar" value="Enviar" />
			<input type="reset" name="btnLimpar" id="btnLimpar" value="Limpar" />
		</div>
	</form>
	
	<div align="center">
		<br /><br /><br />
		<a href="<c:url value="/curso"/>">Voltar</a>
	</div>
	
	<c:import url="/WEB-INF/jsp/rodape.jsp"/>
	
</body>
</html>